def sum_and_avg(list):
    sum = 0
    count = 0
    for x in list:
        if isinstance(x,int) or isinstance(x,float):
            sum += x
            count += 1
    return sum ,sum/count

my_list = [20,15,2.8,'a',35,5.9,-1.8]
rs = sum_and_avg(my_list)
print(rs)
a,b,*list = my_list


def fn(n):
    if n == 0:
        return 1
    elif n == 1:
        return 4
    else:
        return 2*fn(n-1)+fn(n-2)

print(fn(10))

import math
def quadratic(a, b, c):
    der = math.sqrt(b*b-4*a*c)
    x1 = (-b+der)/(2*a)
    x2 = (-b-der)/(2*a)
    return x1,x2

print(quadratic(2, 3, 1))
print(quadratic(1, 3, -4))

def calc(*numbers):
    sum = 0
    for n in numbers:
        sum = sum + n * n
    return sum
print(calc(1, 3, 5, 7))

def f1(a, b, c=0, *args, **kw):
    print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw)

def f2(a, b, c=0, *, d, **kw):
    print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw)

args = (1, 2, 3, 4)
kw = {'d': 99, 'x': '#'}
f1(*args, **kw)

args = (1, 2, 3)
kw = {'d': 88, 'x': '#'}
f2(*args, **kw)


